package com.youlv.yl.dao;

import com.youlv.yl.entity.hotel.Goods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 商品表  Mapper 接口
 * </p>
 *
 * @author fenghe
 * @since 2022-01-19
 */
@Repository
public interface GoodsDao extends BaseMapper<Goods> {

    @Update("update t_goods set stock=stock-#{num} where id=#{id} and stock>=#{num}")
    int updateStock(@Param("id")Long id, @Param("num")Integer num);
}
